package com.test.action.user;

import com.opensymphony.xwork2.ActionSupport;
import com.test.bean.User;
import com.test.service.UserService;

public class SaveUserAction extends ActionSupport
{
	private User user;//什么是模型驱动?

	private UserService service;

	public UserService getService()
	{
		return service;
	}

	public void setService(UserService service)
	{
		this.service = service;
	}

	public User getUser()
	{
		return user;
	}

	public void setUser(User user)
	{
		this.user = user;
	}

	@Override
	public String execute() throws Exception
	{
		this.service.save(user);
		return SUCCESS;
	}
//	
//	@Override
//	public void validate()
//	{
//		if (null==this.user.getFirstname() || "".equals(this.user.getFirstname()))
//		{
//			this.addFieldError("user.firstname", "请输入 "+this.getText("firstname")+" ！");
//			this.addActionError("请输入名字");
//		}
//		if (null==this.user.getLastname() || "".equals(this.user.getLastname()))
//		{
//			this.addFieldError("user.lastname", "请输入 "+this.getText("lastname")+" ！");
//			this.addActionError("请输入姓");
//		}
//		if (this.user.getAge()<1 || this.user.getAge()>150)
//		{
//			this.addFieldError("user.age", "请输入正确的年龄");
//			this.addActionError("请输入正确的年龄");
//		}
//
//	}
	

}
